package com.cosmocoder.persistence.hibernate;

import java.io.Serializable;

import org.hibernate.SessionFactory;

import com.cosmocoder.persistence.AbstractDaoFactory;
import com.cosmocoder.persistence.Dao;
import com.cosmocoder.persistence.DaoFactory;


public class HibernateDaoFactory extends AbstractDaoFactory implements DaoFactory {
	
	private HibernateDaoFactory() {	}
	
	SessionFactory sessionFactory;
	
	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}
			
	protected <EntityType, IdType extends Serializable> Dao<EntityType, IdType> createDao(Class<EntityType> entityClass) {
		HibernateDao<EntityType, IdType> dao = new HibernateDao<EntityType, IdType>();
		dao.setEntityClass(entityClass);
		dao.setSessionFactory(sessionFactory);
		return dao;
	}
}
